import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*
from selenium.webdriver.support.select import Select
testCase="DBshop009_销售管理退货管理搜索"
dr=openBrowser(url)
DBshopLogin(dr,userName,password)
dr.find_element_by_link_text('我的订单').click()
dr.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/div/div[1]/div/div/a[6]').click()
orderNO=dr.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/div/div[2]/div[1]/ul/li[1]/table/thead/tr/th/div/a').text
rootPath=get_pro_rootpath()
writeFile(rootPath+'\public\order2.txt',orderNO)
dr.find_element_by_link_text('退货申请').click()
dr.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/div/div[1]/div/div[2]/a').click()
dr.find_element_by_xpath('//*[@id="order_sn"]').send_keys(orderNO)
dr.find_element_by_xpath('//*[@id="search-order"]').click()
dr.find_element_by_xpath('//*[@id="refund_info"]').send_keys('123')
dr.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/div/div[2]/form/div[11]/button').click()
dr.switch_to.alert.accept()
dr.get(urlAdmin)
DBshopLoginAdmin(dr)
# 1.点击商品管理退货管理。
DBshopEnterMenu2(dr,"销售管理","退货管理")
# 2.点击退货方式，选择框选择“退款到账户余额”点击“搜索”按钮。
s=Select(dr.find_element_by_xpath('/html/body/div[2]/div/div[2]/table/tbody/tr[1]/td[2]/select'))
s.select_by_visible_text('退款到账户余额')
dr.find_element_by_xpath('/html/body/div[2]/div/div[2]/table/tbody/tr[1]/td[6]/button').click()
#断言
if dr.find_element_by_link_text('处理退货').is_displayed():
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(dr)
dr.quit()